package com.hong.spring.mvc.controller;

import com.hong.spring.mvc.exception.SpringException;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

/**
 * @Auther: csh
 * @Date: 2020/7/26 09:47
 * @Description:该类主要是测试spring异常
 */
@Controller
public class ExceptionControler {

    @RequestMapping(value = "/exception",method = RequestMethod.GET)
    @ExceptionHandler({SpringException.class})
    public String exception(){
        int i =0;

        if(i==0){
            throw  new SpringException("出错了!");
        }
        return "result";
    }
}
